Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • logistic regression for each group*holding all other variables constant

    Hi,
    Do you know how I can run the logistic regression for each age or education group holding all other variables constant?

    Thank you,

  • #2
    See -bysort-.
    That said, I would go:
    Code:
    logistic depvar i.age i.group otherindepvar controls
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thank you for your reply. My code is
      Code:

      logistic Livebirths i. EDUCATION HISPANIC hefaminc BLACK Married Divorced, coef

      For the logistic regression on whether the woman had at least one child, or not, calculate the expected probability of having at least one child for a white, nonHispanic woman in each level of education, and hold all other variables constant.

      I can not attach a pic of the result!

      Comment


      • #4
        I attached PIC
        Attached Files

        Comment


        • #5
          https://www.statalist.org/forums/help#adviceextras #4?
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Do you mean this is HW?
            No this is my own work.

            Comment


            • #7
              As you may agree
              For the logistic regression on whether the woman had at least one child, or not, calculate the expected probability of having at least one child for a white, nonHispanic woman in each level of education, and hold all other variables constant.
              sounds like an assignment question.
              As I've decided to trust you, the following toy-example mught be useful:
              Code:
              . use https://www.stata-press.com/data/r17/lbw
              (Hosmer & Lemeshow data)
              
              . logistic low age lwt i.race smoke ptl ht ui
              
              Logistic regression                                     Number of obs =    189
                                                                      LR chi2(8)    =  33.22
                                                                      Prob > chi2   = 0.0001
              Log likelihood = -100.724                               Pseudo R2     = 0.1416
              
              ------------------------------------------------------------------------------
                       low | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                       age |   .9732636   .0354759    -0.74   0.457     .9061578    1.045339
                       lwt |   .9849634   .0068217    -2.19   0.029     .9716834    .9984249
                           |
                      race |
                    Black  |   3.534767   1.860737     2.40   0.016     1.259736    9.918406
                    Other  |   2.368079   1.039949     1.96   0.050     1.001356    5.600207
                           |
                     smoke |   2.517698    1.00916     2.30   0.021     1.147676    5.523162
                       ptl |   1.719161   .5952579     1.56   0.118     .8721455    3.388787
                        ht |   6.249602   4.322408     2.65   0.008     1.611152    24.24199
                        ui |     2.1351   .9808153     1.65   0.099     .8677528      5.2534
                     _cons |   1.586014   1.910496     0.38   0.702     .1496092     16.8134
              ------------------------------------------------------------------------------
              Note: _cons estimates baseline odds.
              
              . predict prob_pred_1 if smoke==1 & race==0
              (option pr assumed; Pr(low))
              (189 missing values generated)
              
              . predict prob_pred_2 if smoke==1 & race==1
              (option pr assumed; Pr(low))
              (137 missing values generated)
              
              . predict prob_pred_3 if smoke==1 & race==2
              (option pr assumed; Pr(low))
              (179 missing values generated)
              
              .
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment

              Working...
              X